<%@page import="com.ulic.customerManApplication.commonmodule.bo.Menu"%>
<%@page import="com.ulic.customerManApplication.usermodule.bo.Role"%>
<%@page import="com.ulic.customerManApplication.usermodule.bo.User"%>
<%@page import="com.ulic.customerManApplication.commonmodule.bo.Activie"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="pg"  uri="http://jsptags.com/tags/navigation/pager" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />     
<title>会员管理系统</title>
<link href="<%= request.getContextPath() %>/html/css/Main.css" rel="stylesheet" />
<script type="text/javascript" src="<%= request.getContextPath() %>/html/js/PopupCalendar.js"></script>
<script type="text/javascript" src="<%= request.getContextPath() %>/html/js/prototype.js"></script>
<script type="text/javascript" src="<%= request.getContextPath() %>/html/js/buffalo.js"></script>
<script type="text/javascript" src="<%= request.getContextPath() %>/html/js/pims.js"></script>
</head>
<body>
<div class="container">
    <div class="wrap clear">
        <div class="sub_wp_right">
        	<div class="rt_tt">
            	<h3 class="tittle">设置权限</h3>
            </div>
             <div class="ct">
                	<h3 class="sm_tt">权限属性</h3>
                    <div class="tiaojian">
                    	<form action="<%= request.getContextPath() %>/user/setedPermission.do" name="listForm" method="post">
                        	<input type="hidden" name="userid" value='<s:property value="#request.userid"/>'>
                        	<input type="hidden" name="organOid" value="${organOid }"/>
<div class="tbFormPanel">
	<table cellspacing="0" cellpadding="1" border="0">
		<tr>
			<th>功能权限:</th>
			<td>
				<%
					List<Menu> menuList = (List<Menu>)request.getAttribute("menuList");
					int[] pmenu = (int[])request.getAttribute("pmenu");
					for(int i = 0; i < menuList.size(); i++) {
						String mlabel = String.valueOf(Math.random());
						Menu menu = menuList.get(i);
						int moid = menu.getOid();
						boolean mchecked = false;
						for(int j = 0; j < pmenu.length; j++) {
							if(pmenu[j] == moid) {
								mchecked = true;
								break;
							}
						}
						if(mchecked) {
							out.print("<input type='checkbox' name='pmenu' checked='checked' value='" + moid + "' id='" + mlabel+ "'><label for='" + mlabel + "'>" + menu.getName() + "</label>");
						} else {
							out.print("<input type='checkbox' name='pmenu' value='" + moid + "' id='" + mlabel+ "'><label for='" + mlabel + "'>" + menu.getName() + "</label>");
						}
						if((i+1)%4==0){
						//一个菜单结束后的换行
							out.print("<br>");
						}
					}
				%>
			</td>
		</tr>
		<tr>
			<th>用户角色:</th>
			<td>
				<select name="roleId">
				<%
					List<Role> roleList = (List<Role>)request.getAttribute("roleList");
					int[] roles = (int[])request.getAttribute("roles");
					for(int i = 0; i < roleList.size(); i++) {
						Role role = roleList.get(i);
						int roid = role.getOid();
						boolean mchecked = false;
						for(int j = 0; j < roles.length; j++) {
							if(roles[j] == roid) {
								mchecked = true;
								break;
							}
						}
						if(mchecked) {
							out.print("<option  value='" + role.getOid() + "'  selected >"+role.getName()+"</option>");
						} else {
							out.print("<option  value='" + role.getOid() + "'  >"+role.getName()+"</option>");
						}
					}
				%>
				</select>
			</td>
		</tr>
		<tr>
			<th>用户状态:</th>
			<td>
				<select name="activieOid">
				<%
					List<Activie> activieList = (List<Activie>)request.getAttribute("activieList");
					int[] activies = (int[])request.getAttribute("activies");
					for(int i = 0; i < activieList.size(); i++) {
						Activie activie = activieList.get(i);
						int aoid = activie.getOid();
						boolean mchecked = false;
						for(int j = 0; j < activies.length; j++) {
							if(activies[j] == aoid) {
								mchecked = true;
								break;
							}
						}
						if(mchecked) {
							out.print("<option  value='" + activie.getOid() + "'  selected >"+activie.getName()+"</option>");
						} else {
							out.print("<option  value='" + activie.getOid() + "'  >"+activie.getName()+"</option>");
						}
					}
				%>
				</select>
			</td>
		</tr>
	</table>
	<div class="tbSubmitBar">
		<input type="submit" name="clear" value="保存"/><input type="button" name="clear" value="取消" onclick="history.back()"/>
	</div>
</div>
                        </form>
                    </div>
             </div>
        </div>
       
    </div>
</div>
</body>
</html>